package com.zwl.sjzmanagement.controller;

import com.atguigu.tingshu.common.result.Result;
import com.zwl.minio.config.MinioProperties;
import com.zwl.minio.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("api/upload")
public class FileUploadApiController {

    @Autowired
    private MinioProperties minioProperties;

    @Autowired
    private FileService fileService;

    // 对于前端传的文件对象 后端统一用MultipartFiled对象来接收
    @PostMapping("/fileUpload")
    public Result fileUpload(MultipartFile file) throws Exception {
        String picUrl = fileService.fileUpload(file);
        return Result.ok(picUrl);
    }

}